#pragma once

#ifndef __INI_MANAGER_H__
#define __INI_MANAGER_H__

#include "Common.h"
#include "LogManager.h"
#include "ConnectionManager.h"
#include "GrabManager.h"

typedef struct
{
	ConnectionOptions ConnectionOptions;
	GrabOptions GrabOptions;
} Configuration;

// Manager for ini file.
class IniManager
{
public:
	static bool TryUpdateKey(const string& value, const string& fileName);

	// Read the given ini file.
	static bool Read(const string& filename, Configuration& configuration);

private:
	// Try to read a string from the ini file.
	static bool TryReadString(const string& section, const string& key, const string& defaultValue, string& result);

	// Try to read an integer from the ini file.
	static bool TryReadInteger(const string& section, const string& key, const int& defaultValue, int& result);

	// Try to read coordinates from the ini file.
	static bool TryReadCoordinates(const string& section, const string& key, const string& defaultValue, vector<POINT>& result);

	// Try to read coordinates from the ini file.
	static bool TryReadCoordinates(const string& section, const string& key, const string& defaultValue, POINT& result);

	// Try to read multiple coordinates from the ini file.
	static bool TryReadMultipleCoordinates(const string& section, vector<POINT>& result);

	// Try to read coordinates from a given value.
	static bool TryReadCoordinates(const string& value, vector<POINT>& result);

	// Try to read coordinates from a given value.
	static bool TryReadCoordinates(const string& value, POINT& result);

	// Removes all leading and trailing white-space characters from the value.
	static string Trim(const string& value);
};

#endif  // __INI_MANAGER_H__

